package cn.accp.kzy.service;

import java.util.List;
import java.util.Map;

import cn.accp.kzy.dao.BBSSectionDao;
import cn.accp.kzy.dao.BBSTopicDao;
import cn.accp.kzy.dao.impl.BBSSectionDaoImpl;
import cn.accp.kzy.dao.impl.BBSTopicDaoImpl;
import cn.accp.kzy.model.BBSTopic;
import cn.accp.kzy.model.BBSUser;
import cn.accp.kzy.util.PageInfo;

public class BBSTopicManager {
	private BBSTopicDao tdi = new BBSTopicDaoImpl();
	private BBSSectionDao sdi = new BBSSectionDaoImpl();

	public void addTopic(BBSTopic topic) {
		tdi.addTopic(topic);
		sdi.updateTopicCount(topic.getTsid());
	}
	
	public List<BBSTopic> getBBSTopicByUser(BBSUser user,PageInfo pageInfo) {
		return tdi.getBBSTopicByUser(user,pageInfo);
	}
	
	public void updateClickCount(BBSTopic topic) {
		tdi.updateClickCount(topic);
		sdi.updateClickCount(topic.getTsid());
	}
	
	public BBSTopic getBBSTopicById(int tid) {
		return tdi.getBBSTopicById(tid);
	}
	
	public List<BBSTopic> getBBSTopicBySection(int sid,PageInfo pageInfo){
		return tdi.getBBSTopicBySection(sid, pageInfo);
	}
	
	public int getAllTopicCount() {
		return tdi.getAllTopicCount();
	}
	public List<BBSTopic> getBBSTopicByDate(PageInfo pageInfo) {
		return tdi.getBBSTopicByDate(pageInfo);
	}
	
	
	public List<BBSTopic> getBBSTopic(String type,Map<String, Object> session,int sid,PageInfo pageInfo) {
		return tdi.getBBSTopic(type, session, sid, pageInfo);
	}
	public BBSTopic getLastBBSTopicBySid(int sid) {
		return tdi.getLastBBSTopicBySid(sid);
	}
	public int getTopicCountBySid(int sid) {
		return tdi.getTopicCountBySid(sid);
	}
}
